define(["jquery", "easy-admin"], function ($, ea) {

    var init = {
        table_elem: '#currentTable',
        table_render_id: 'currentTableRenderId',
        index_url: 'distributor.distributor/index',
        add_url: 'distributor.distributor/add',
        edit_url: 'distributor.distributor/edit',
        delete_url: 'distributor.distributor/delete',
        export_url: 'distributor.distributor/export',
        modify_url: 'distributor.distributor/modify',
        adopt_url: 'distributor.distributor/adopt_url',
        reject_url: 'distributor.distributor/reject_url',
        looksub_url: 'distributor.distributor/looksub_url',
    };
    var Controller = {
        index: function () {
            ea.table.render({
                init: init,
                toolbar: ['refresh'],
                cols: [[
                    {field: 'nickname', title: '用户昵称', search: false},
                    {field: 'name', title: '分销商姓名'},
                    {field: 'phone', title: '分销商手机号'},
                    {field: 'promotion_number', title: '推广人数'},
                    {field: 'avatar', minWidth: 80, title: '头像', search: false, templet: ea.table.image},
                    {field: 'commission', title: '可提现佣金', search: false},
                    {field: 'endmoney', title: '已提现佣金', search: false},
                    {field: 'dis_level', title: '分销商等级', edit: 'text',search: false,selectList: {0:'请重新设置',1: '一级',2: '二级',3: '三级',4: '四级',5: '五级'}},
                    {field: 'examine', title: '审核状态',selectList: {0: '待审核',1: '已审核',2: '已拒绝'}},
                    {field: 'status', title: '分销商状态', templet: ea.table.switch, search: false},
                    {field: 'create_time', title: '注册时间', search: false},
                    {title: '操作', templet: ea.table.tool,operat:[
                        [
                            {
                                text: '通过',
                                title: '确定通过吗？',
                                url: init.adopt_url,
                                method: 'request',
                                auth: 'edit',
                                class: 'layui-btn layui-btn-xs layui-btn-success'
                            }
                       ],
                       [
                            {
                                text: '拒绝',
                                url: init.reject_url,
                                method: 'open',
                                auth: 'edit',
                                class: 'layui-btn layui-btn-xs layui-btn-danger'
                            }
                        ],
                        [
                            {
                                text: '编辑',
                                url: init.edit_url,
                                method: 'open',
                                auth: 'edit',
                                class: 'layui-btn layui-btn-xs layui-btn-success',
                               // extend: 'data-full="true"',
                            }
                       ],
                       [
                           {
                               text: '查看下级成员',
                               url: init.looksub_url,
                               method: 'open',
                               auth: 'edit',
                               class: 'layui-btn layui-btn-xs layui-btn-success',
                              // extend: 'data-full="true"',
                           }
                      ]
                    ]},
                ]],
            });
            ea.listen();
        },
        add: function () {
            ea.listen();
        },
        edit: function () {
            ea.listen();
        },
        reject_url: function () {
            ea.listen();
        },
        looksub_url: function () {
            ea.listen();
        }
    };
    return Controller;
});